<template>
  <div class="peo-box">
    <div
      class="peo-item"
      @mouseenter.stop="changeindex(dataObj.friend_id)"
      @mouseleave.stop="changeindex(-1)"
      @click="changeChat(dataObj)"
      :class="{
        active: dataObj.friend_id === index && !dataObj.open,
        ok: dataObj.open,
      }"
    >
      <img
        style="width: 45px; height: 45px; border-radius: 50%; display: block"
        :src="dataObj.friend_avatar"
        alt=""
      />
      <div class="peo-item-content">
        <div
          style="font-size: 14px; color: #333"
          :class="{ foncolor: dataObj.open }"
        >
          {{ dataObj.friend_nickname }}
        </div>
        <div
          style="font-size: 12px; color: #565050; margin-top: 10px"
          :class="{ foncolor: dataObj?.open }"
        >
          {{ dataObj.friend_signature }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  props: {
    dataObj: {
      type: Array,
      default: () => { }
    }
  },
  data() {
    return {
      index: -1,
      openid: ''
    }
  },
  methods: {
    changeindex(index) {
      this.index = index
    },
    changeChat(item) {
      this.$emit('changefriend', item)
    }
  }
}
</script>

<style lang="scss" scoped>
.peo-box {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  .active {
    background: #f5f5f5;
  }
  .ok {
    background: rgb(58, 58, 157) !important;
  }
  .peo-icon {
    width: 20px;
    height: 20px;
    background: red;
    border-radius: 50%;
    display: flex;
    margin-left: 10px;
    position: absolute;
    bottom: 15px;
    right: 18px;
    font-size: 12px;
    color: #fff;
    align-items: center;
    justify-content: center;
  }
  .foncolor {
    color: #fff !important;
  }
  .peo-item {
    width: 100%;
    height: 80px;
    padding: 20px;
    display: flex;
    position: relative;
    .peo-item-content {
      display: flex;
      flex-direction: column;
      margin-left: 20px;
      position: relative;
    }
    .peo-item-time {
      position: absolute;
      right: 20px;
      top: 20px;
      color: #999;
      font-size: 12px;
    }
  }
}
</style>